﻿#include "connectthread.h"
ConnectThread::ConnectThread(SOCKET sockCli,QObject *parent) :
    sockCli(sockCli),
    QObject(parent)
{
    qRegisterMetaType<Message>("Message");//不注册会警告
}
void ConnectThread::connectWithServer(){
    while (true) {
        qDebug()<<"wait:";
        qDebug()<<sockCli;
        recv(sockCli, (char*)&m, sizeof(m), 0);
        qDebug()<<u8"消息类型:"<<m.messageType;
        switch(m.messageType){
            case 2://私聊消息
                this->noticeReceviceMessage(m);
            break;
            case 4://拉取好友列表
                qDebug()<<u8"connectWithServer:拉取好友列表";
                this->noticeGetFirendList(m);
            break;
            case 5://请求添加好友信息
                qDebug()<<u8"connectWithServer:请求添加好友信息";
                this->requestAddFriend(m);
            break;
            case 6://添加好友成功
                qDebug()<<u8"connectWithServer:添加好友成功";
                this->AddFriendSucessfully(m);
            break;
            case 7://更新新好友信息
                qDebug()<<u8"connectWithServer:更新新好友信息";
                this->updateNewFriend(m);
            break;
            default:
            ;
        }
    }
}
